<!--
 * 配置管理
 * @author luguoxiang
 * @date 2023-03-27
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  <t-form ref="form" :data="model" :colon="true">
    <t-form-item label="银行名称" name="backName">
      <t-input v-model="model.backName" placeholder="例：中国银行" />
    </t-form-item>
    <t-form-item label="银行账户名" name="accountName">
      <t-input v-model="model.accountName" placeholder="例：王小明" />
    </t-form-item>
    <t-form-item label="银行账号" name="backAccount">
      <t-input v-model="model.backAccount" placeholder="例：62205846856846545" />
    </t-form-item>
  </t-form>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import api from '@/api/userConfig';

const code = 'bank';
const model = ref({});
const form = ref();

function load() {
  api.get(code).then((res) => {
    model.value = res ?? {};
  });
}

defineExpose({
  submit() {
    form.value.validate().then(() => {
      api.set(code, model.value);
    });
  },
  reset() {
    return form.value.reset();
  },
});

onMounted(() => {
  load();
});
</script>
